﻿using Goooodbye.Core.Services;
using NLog;
using System;
using System.Net.Http;
using System.Reflection;
using System.Web.Http;

namespace Goooodbye.Presentation.WebApi.Controllers
{
    public class IndexController : ApiController
    {
        private static readonly Logger logger = LogManager.GetLogger(Assembly.GetExecutingAssembly().GetName().Name);
        private IDictService dictService;

        public IndexController(IDictService dictService)
        {
            this.dictService = dictService;
        }

        [HttpGet]
        public String Index()
        {
            return "It works.";
        }

        [HttpGet]
        public int Count()
        {
			var req = Request.GetOwinContext().Request;
            logger.Debug($"[{req.RemoteIpAddress}] [{req.Method}] {req.Uri}");
            return dictService.Query().Total;
        }
    }
}
